/**
 * Created by hhshi on 13-10-23.
 */
var mysql = require('./DB');

/**
 * 获取用户信息方法
 * @param username 用户名
 * @param password 密码
 * @param callback 数据操作回调
 */
exports.getUser = function(username,password,callback){
    var user = [username,password];
    mysql.query("SELECT * FROM user WHERE name = ? AND password = ?",user,function(err,results){
        callback(results);
    });
};

/**
 * 检查用户名是否存在
 * @param username 要检测的用户名
 * @param callback 数据操作回调
 */
exports.checkUserName = function(username,callback){
    mysql.query("SELECT * FROM user WHERE name = ?",username,function(err,results){
        callback(results);
    });
};

/**
 * 增加新用户方法
 * @param newuser 要增加的用户信息
 * @param callback 数据操作回调
 */
exports.addNewUser = function(newuser,callback){
    mysql.query("INSERT INTO user SET ? ",newuser,function(err,results){
        callback(results);
    });
};